from django.db import models

# Create your models here.
#用户
class User(models.Model):
    username=models.CharField(max_length=32,unique=True)
    password=models.CharField(max_length=500)

    class Meta:
        db_table='user'

#新闻
class News(models.Model):
    title=models.CharField(max_length=32,verbose_name='标题')
    content=models.CharField(max_length=1000)
    total_comment=models.IntegerField(default=0,verbose_name='总评论数')
    total_views=models.IntegerField(default=0,verbose_name='总浏览数')

    class Meta:
        db_table='news'

#评论
class Comment(models.Model):
    content=models.CharField(max_length=1000,verbose_name='评论')
    user=models.ForeignKey('User',on_delete=models.CASCADE)
    news=models.ForeignKey('News',on_delete=models.CASCADE)
    comment_count=models.IntegerField(default=0,verbose_name='评论次数')

    class Meta:
        db_table='comment'